package com.example.jiaopin.Mapper;
import com.example.jiaopin.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM users WHERE userID = #{userID}")
    User getUserById(Integer userID);

    @Insert("INSERT INTO users(username, password, role, classID) VALUES(#{username}, #{password}, #{role}, #{classID})")
    @Options(useGeneratedKeys = true, keyProperty = "userID")
    void insertUser(User user);

    @Update("UPDATE users SET username = #{username}, password = #{password}, role = #{role}, classID = #{classID} WHERE userID = #{userID}")
    void updateUser(User user);

    @Delete("DELETE FROM users WHERE userID = #{userID}")
    void deleteUser(Integer userID);
}
